/*
 * @Author: lusx 
 * @Date: 2020-04-29 10:35:28 
 * @Last Modified by: lusx
 * @Last Modified time: 2020-05-03 15:54:53
 */

import React from 'react';
import Loadable from 'react-loadable';

const loadingComponent = (props) => {
    if (props.pastDelay) {
        return <div>Loading...</div>;
    }
    else if (props.error) {
        return <div>Sorry, there was a problem loading the page.</div>;
    } else if (props.timedOut) {
        return <div>Taking a long time...请重新进入该页面</div>;
    }
    else {
        return null;
    }
};

//过场组件默认采用通用的，若传入了loading，则采用传入的过场组件
export default (loader, loading = loadingComponent) => {
    return Loadable({
        loader,
        loading,
        delay: 300,
        timeout: 5000,
    });
}